<template>
	<view class="main animated fadeIn faster">
		<TitleBarVue :title="title"/>
		<view class="Tips" v-if="user.length!=0">-最近有<text>{{visitCount}}</text>人访问了你-</view>
		<view class="JoinInList" v-if="user.length!=0"  :style="{margin: (user.length!=0&&$store.state.user.accountType==1)? '20rpx auto' : '0 auto'}">
			<view class="item" v-for="(item,index) in firstTwoItems" :key="index">
				<view class="info" @click="$store.state.user.accountType==1? null : touser(item.fromUid)">
					<view class="icon">
						<image v-bind:src="item.avatar" class="img-bg-img" mode="aspectFill" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
						<view class="sex" style="position: absolute;bottom: 7rpx;right: 0rpx;">
							<image v-if="item.gender==2" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%203404.png"></image>
							<image v-if="item.gender==1" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%94%B7.png"></image>
						</view>
					</view>
					<view class="detailed" style="margin-left: 20rpx;">
						<view class="name">{{item.nickname}}</view>
					<!-- 	<view class="rank">
							<view class="icon">
								<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%203178.png"></image>
							</view>
							<view class="txt">最强王者</view>
						</view> -->
						<view class="desc">他在{{item.createTime}}访问了你的主页</view>
					</view>
				</view>
			</view>
		</view>
		<view class="MemberBar" v-if="user.length!=0&&$store.state.user.accountType==1">
			<view class="txt">开通会员,查看全部对你感兴趣的人</view>
			<view class="btn" @click="OpenBulletFrame">立即解锁访客</view>
			<view class="desc">仅保留30天内的访客记录</view>
		</view>
		<view class="JoinInList pb-5" v-if="user.length!=0" :style="{margin: (user.length!=0&&$store.state.user.accountType==1)? '20rpx auto' : '-25rpx auto'}">
			<view class="item" v-for="(item,index) in remainingItems" :key="index">
				<view class="info"  @click="$store.state.user.accountType==1? null : touser(item.fromUid)">
					<view class="icon">
						<image v-bind:src="item.avatar" class="img-bg-img " :class="$store.state.user.accountType==1?'bluricon':''" style="width: 100rpx;height: 100rpx;border-radius: 50%;" mode="aspectFill"></image>
						<view class="sex" style="position: absolute;bottom: 7rpx;right: 0rpx;">
							<image v-if="item.gender==2" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%203404.png"></image>
							<image v-if="item.gender==1" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%94%B7.png"></image>
						</view>
					</view>
					<view class="detailed" style="margin-left: 20rpx;">
						<view :class="$store.state.user.accountType==1?'blurname':''">{{item.nickname}}</view>
					<!-- 	<view class="rank">
							<view class="icon">
								<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%203178.png"></image>
							</view>
							<view class="txt">最强王者</view>
						</view> -->
						<view class="desc">他在{{item.createTime}}访问了你的主页</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="user.length==0 && loaded" style="width: 100%; margin-top: 200rpx;"  >
		<text class="position-relative d-flex font-bold font30" style="top: 405rpx;justify-content: center;align-items: center;">您暂时还没有访客记录</text>
		<image class="position-relative" style="top: -73rpx;left: 58rpx;width: 80%;" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/xiaoda.png"></image>
		</view>
		<view class="Bullet_Frame z-index-100" :style="{display: display}" @click="CloseBulletFrame">
			<view class="bg" @click.stop="CloseBullet">
				<swiper class="swiper" :indicator-dots="indicatorDots">
					<swiper-item v-for="i in 4" :key="i.id">
						<view class="swiper-item">
							<view class="img">
								<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%205032.png"></image>
							</view>
							<view class="text">SVIP专属优惠券</view>
							<view class="desc">解锁SVIP每周专属优惠券,下单更优惠</view>
						</view>
					</swiper-item>
				</swiper>
				<scroll-view class="scroll-view_H" scroll-x="true">
					<view 
						:class="['scroll-view-item_H','position-relative', 
						select === index? 'current' : '']" 
						 @click="ChangeSelect(index)"
						v-for="(i, index) in memberList" :key="i.id">
						<view class="title">{{i.name}}</view>
						<view class="amount">
							<view class="text">￥</view>
							<view class="num">{{i.price}}</view>
						</view>
						<view class="desc">
							<view class="num">{{(i.price/30).toFixed(2)}}元</view>
							<view class="text">/ 天</view>
						</view>
						<view class="commonLinerbg position-absolute rounded15 font-bold" style="top: -20rpx; left: 6rpx; padding: 4rpx 8rpx;">限时</view>
					</view>
				</scroll-view>
				<view class="PayOptions">
					<view class="icon">
						<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20241115141319.png"></image>
					</view>
					<view class="option">支付宝</view>
					<view class="arrow-r">
						<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%203365.png"></image>
					</view>
				</view>
				<view class="btn">快来点我开通SVIP</view>
				<view class="agreement">开通即表示同意《悦小嗒协议》</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { memberApi } from '../../http/memberApi';
	import { userApi } from '../../http/userApi';
	import TitleBarVue from '../../components/TitleBar.vue';
	import store from '@/store/index.js';
	export default {
		data() {
			return {
				indicatorDots: true,
				display: 'none',
				bgcolor:'#fff',
				title: '最近访客',
				select: 0,
				visitCount:0,
				memberList: [],
				user: [],
				isLastPage: false,
				loaded: false,
				param:{
					type: 4,
					pageIndex: 1,
					pageSize: 9
				},
			}
		},
		components:{TitleBarVue},
		methods: {
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			touser(id){
			if(id==this.$store.state.user.uid){
				return
			}
			uni.navigateTo({
			    url: `/pagesMain/HomePage/HomePage?id=${id}`
			});	
			},
			OpenBulletFrame() {
				this.display = 'block'
				this.bgcolor = 'transparent'
				this.queryMember()
			},
			CloseBulletFrame() {
				this.display = 'none'
				this.bgcolor = '#fff'
			},
			CloseBullet(e) {
				e.stopPropagation();
			},
			ChangeSelect(index) {
				this.select = index
			},
			async Relation(){
				this.loaded = false
				let res = await userApi.getRelationFrom(this.param);
				console.log(res.records.length);
				if (res.records.length < this.param.pageSize) {
				    this.isLastPage = true
				}
				this.loaded = true
				const start = this.user.length;
				this.user.splice(start, 0, ...res.records);
				console.log(this.user);
			},
			async queryMember() {
				let params = {
					pageIndex: 1,
					pageSize: 10,
					type: 2
				}
				const res = await memberApi.member(params)
				this.memberList = res.records
				console.log(this.memberList);
			}
		},
		onReachBottom() {
			if(this.isLastPage) return
			this.param.pageIndex++
			this.Relation()
		},
		 computed: {
		    // 计算属性，返回数组的前两个元素
		    firstTwoItems() {
		      return this.user.slice(0, 1);
		    },
		    // 计算属性，返回数组的其余元素
		    remainingItems() {
		      return this.user.slice(1);
		    }
		  },
		onLoad() {
			this.visitCount=this.$store.state.user.visitCount;
			this.Relation()
		}
	}
</script>

<style scoped lang="scss">
.main {
	background: #fff;
	overflow: hidden;
	position: relative;
	.content {
		width: 100%;
	}
	.Tips {
		margin-top: 210rpx;
		color: #B3B3B4;
		text-align: center;
		text {
			color: #231815;
		}
	}
	.JoinInList {
		width: 730rpx;
		border-radius: 50rpx;
		background-color: #fff;
		overflow: hidden;
		.item {
			width: 700rpx;
			height: 150rpx;
			margin: 25rpx auto 25rpx;
			background-color: #f5f5f5;
			border-radius: 15rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.info {
				display: flex;
				align-items: center;
				margin-left: 20rpx;
				.icon {
					position: relative;
					.bluricon {
						filter: blur(7px);
					}
					image {
						width: 152rpx;
						height: 152rpx;
					}
					.sex {
						position: absolute;
						bottom: 25rpx;
						right: 25rpx;
						image {
							width: 30rpx;
							height: 30rpx;
						}
					}
				}
				.detailed {
					.name {
						font-size: 30rpx;
					}
					.blurname {
						filter: blur(5px);
						margin-bottom: 4rpx;
						color: #231815;
						font-size: 30rpx;
						image {
							filter: blur(3px);
							width: 130rpx;
							height: 30rpx;
						}
					}
					.rank {
						display: flex;
						padding: 4rpx 0;
						.icon {
							background-color: #b73de3;
							width: 50rpx;
							border-radius: 15rpx 0 0 15rpx;
							margin: 0;
							display: flex;
							justify-content: center;
							align-items: center;
							image {
								width: 24.96rpx;
								height: 17.76rpx;
							}
						}
						.txt {
							color: #B73DE3;
							background-color: #e7cbf2;
							width: 110rpx;
							text-align: center;
							font-size: 24rpx;
							padding: 4rpx 6rpx 4rpx 0 ;
							border-radius: 0 10rpx 10rpx 0;
						}
					}
					.desc {
						color: #595757;
						font-size: 24rpx;
					}
				}
			}
			.btn {
				width: 150rpx;
				height: 60rpx;
				border-radius: 30rpx;
				color: #fff;
				margin-right: 50rpx;
				background: linear-gradient( 90deg, #ED65CE 0%, #E966CF 2%, #859BF0 69%, #5DB0FE 99%);
				display: flex;
				justify-content: center;
				align-items: center;
				image {
					width: 35rpx;
					height: 20rpx;
					background-color: #fff;
				}
			}
		}
	}
	.MemberBar {
		width: 650rpx;
		height: 276rpx;
		margin: 0 auto;
		border-radius: 10rpx;
		background-image: url(https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%203157.png);
		background-size: contain;
		overflow: hidden;
		.txt {
			color: #231815;
			font-size: 30rpx;
			text-align: center;
			margin: 40rpx 0 30rpx;
		}
		.btn {
			width: 400rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin: 0 auto;
			border-radius: 50rpx;
			color: #fff;
			text-align: center;
			font-size: 30rpx;
			background: linear-gradient(90deg, #ED65CE 0%, #E966CF 2%, #859BF0 69%, #5DB0FE 99%);
		}
		.desc {
			color: #5DB0FE;
			text-align: center;
			margin-top: 15rpx;
		}
	}
	.Bullet_Frame {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(23, 28, 97, .6);
		.bg {
			position: fixed;
			bottom: 150rpx;
			left: 50%;
			transform: translateX(-50%);
			border-radius: 35rpx;
			width: 730rpx;
			height: 70vh;
			overflow: hidden;
			background-color: #fff;
			.swiper {
				height: 450rpx;
				.swiper-item {
					display: block;
					height: 100%;
					line-height: 300rpx;
					text-align: center;
					display: flex;
					align-items: center;
					flex-direction: column;
					.img {
						margin-top: 70rpx;
						width: 316rpx;
						height: 195rpx;
						image {
							width: 100%;
							height: 100%;
							vertical-align: top;
						}
					}
					.text {
						width: 100%;
						height: 85rpx;
						line-height: 90rpx;
						font-size: 34rpx;
						font-weight: 700;
					}
					.desc {
						height: 30rpx;
						line-height: 30rpx;
						font-size: 24rpx;
						color: #717071;
					}
				}
			}
			.scroll-view_H {
				white-space: nowrap;
				width: 100%;
				height: 302rpx;
				margin-top: 20rpx;
				.scroll-view-item_H {
					overflow: visible;
					margin-top: 50rpx;
					display: inline-block;
					text-align: center;
					width: 29%;
					height: 280rpx;
					border-radius: 38rpx;
					background: #f5f5f5;
					margin: 20rpx 12rpx 0;
					.title {
						display: flex;
						justify-content: center;
						height: 50rpx;
						margin-top: 30rpx;
						font-size: 34rpx;
						color: #3E3A39;
					}
					.amount {
						display: flex;
						align-items: center;
						justify-content: center;
						height: 140rpx;
						color: #231815;
						.num {
							font-size: 60rpx;
							font-weight: 700;
						}
						.text {
							margin-top: 20rpx;
							font-weight: 700;
						}
					}
					.desc {
						display: flex;
						justify-content: center;
						margin-bottom: 20rpx;
						font-size: 24rpx;
						color: #231815;
						.num {
							margin-right: 6rpx;
						}
					}
				}
				.scroll-view-item_H:first-child {
					margin-left: 30rpx;
				}
				.scroll-view-item_H:last-child {
					margin-right: 30rpx;
				}
				.current {
					background: #CFF0FB;
					border: 1px solid #46C4FF;
				}
			}
			.PayOptions {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 66rpx;
				.icon {
					margin-left: 74rpx;
					margin-right: 26rpx;
					image {
						width: 64rpx;
						height: 64rpx;
					}
				}
				.option {
					flex: 1;
					color: #231815;
					font-size: 28rpx;
				}
				.arrow-r {
					display: flex;
					align-items: center;
					margin-right: 85rpx;
					image {
						width: 10.52rpx;
						height: 9.86rpx;
					}
				}
			}
			.btn {
				width: 90%;
				margin: 44rpx auto 28rpx;
				text-align: center;
				font-size: 32rpx;
				color: #fff;
				height: 87rpx;
				line-height: 87rpx;
				border-radius: 50rpx;
				background: linear-gradient( 90deg, #ED65CE 0%, #E966CF 2%, #859BF0 69%, #5DB0FE 99%);
			}
			.agreement {
				color: #717071;
				font-size: 24rpx;
				text-align: center;
			}
		}
	}
}
.title {
	display: flex;
	align-items: center;
	height: 80rpx;
	margin-right: 47rpx;
	text {
		flex: 1;
		margin-right: 50rpx;
		font-size: 32rpx;
		text-align: center;
	}
}
.commonLinerbg {
	background: linear-gradient( 90deg, #5DAFFD 0%, rgba(93,175,253,0.8) 1%, #E7B9FB 100%);
}
.pt-300 {
	padding-top: 300rpx;
}
</style>
